package com.lydia.service;

/**
 * @author Admin
 */

public enum PostgresColumnType {
    VARCHAR("VARCHAR","VARCHAR","VARCHAR"),
    NUMERIC("NUMERIC","NUMBER","NUMERIC"),
    NUMBER_BIGINT("NUMBER_BIGINT","NUMBER","BIGINT"),
    NUMBER_INT("NUMBER_INT","INT","INT"),
    INT("INT","INT","INT"),
    INT8("INT8","INT","BIGINT"),
    INT4("INT4","INT","INT"),
    INT2("INT2","INT","SMALLINT"),
    BOOL("BOOL","BIT","BOOL"),
    BPCHAR("BPCHAR","CHAR","CHAR"),
    CHAR("CHAR","CHAR","CHAR"),
    BIT("BIT","BIT","BIT"),
    JSON("JSON","CLOB","JSON"),
    FLOAT4("FLOAT4","FLOAT","FLOAT"),
    FLOAT8("FLOAT8","FLOAT","FLOAT"),
    UUID("UUID","VARCHAR","VARCHAR"),
    TEXT("TEXT","CLOB","TEXT"),
    DATE("DATE","DATETIME","DATE"),
    TIMESTAMP("TIMESTAMP","DATETIME","TIMESTAMP"),
    TIMESTAMPTZ("TIMESTAMPTZ","DATETIME","TIMESTAMP"),
    BYTEA("BYTEA","BLOB","BLOB"),
;

    String oracleType;
    String mysqlType;
    String postgresType;
    PostgresColumnType(String postgresType, String oracleType, String mysqlType) {
        this.oracleType = oracleType;
        this.mysqlType = mysqlType;
        this.postgresType = postgresType;
    }


    public String postgresType() {
        return postgresType;
    }


    public static String getOracleType(String  postgresType){
        for (PostgresColumnType sourceEnum : PostgresColumnType.values()){
            if (sourceEnum.postgresType().equals(postgresType)){
                return sourceEnum.oracleType;
            }
        }
        return null;
    }
    public static String getMysqlType(String  postgresType){
        for (PostgresColumnType sourceEnum : PostgresColumnType.values()){
            if (sourceEnum.postgresType().equals(postgresType)){
                return sourceEnum.mysqlType;
            }
        }
        return null;
    }

}
